package com.zdkj.subway.stm.controller;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zdkj.common.core.constant.CommonConstants;
import com.zdkj.common.core.constant.SecurityConstants;
import com.zdkj.common.core.util.R;
import com.zdkj.common.log.annotation.SysLog;
import com.zdkj.common.security.annotation.Inner;
import com.zdkj.common.security.service.PigxUser;
import com.zdkj.common.security.util.ObjectUtils;
import com.zdkj.common.security.util.SecurityUtils;
import com.zdkj.subway.stm.constant.StmConstans;
import com.zdkj.subway.stm.constant.StmTableCommon;
import com.zdkj.subway.stm.dto.in.SwStInputPassengerWorkNonTimelyTicketDTO;
import com.zdkj.subway.stm.dto.in.SwStInputPassengerWorkTimelyTicketInputDTO;
import com.zdkj.subway.stm.dto.in.SwStInvalidTicketDTO;
import com.zdkj.subway.stm.entity.*;
import com.zdkj.subway.stm.fegin.SubwayStService;
import com.zdkj.subway.stm.mapper.SwStConductorSettleMapper;
import com.zdkj.subway.stm.mapper.SwStInputPassengerWorkTicketMapper;
import com.zdkj.subway.stm.mapper.SwStInvalidTicketMapper;
import com.zdkj.subway.stm.mapper.SwStReportErrorAlterAppayMapper;
import com.zdkj.subway.stm.service.*;
import com.zdkj.subway.stm.util.BeanUtilsStm;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;


/**
 * 乘客事务退换票
 *
 * @author cuilei
 * @date 2020-05-25 13:38:12
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/swstinputpassengerworkticket")
@Api(value = "swstinputpassengerworkticket", tags = "乘客事务退换票管理")
public class SwStInputPassengerWorkTicketController {
    private final static String TIMELY = "0";//即时退换票
    private final static String NON_TIMELY = "1";//非即时退换票
    private final static String SEND = "1";//无效票发送状态
    private final static String STATION = "0";
    private final SwStInputPassengerWorkTicketService swStInputPassengerWorkTicketService;
    private final SubwayStService subwayStService;
    private final SwStmStationDataEntryLogService swStmStationDataEntryLogService;
	@Resource
    private SwStInputPassengerWorkTicketMapper swStInputPassengerWorkTicketMapper;
    @Resource
    private final SwStInvalidTicketMapper swStInvalidTicketMapper;
    @Resource
    private final SwPmTicketCardTypeParamService swPmTicketCardTypeParamService;
    @Resource
    private final SwStTicketInformationCheckService swStTicketInformationCheckService;
    @Resource
    SwStReportErrorAlterAppayMapper swStReportErrorAlterAppayMapper;
    @Resource
    private final SwStRecoveryService swStRecoveryService;
    @Resource
    private final SwStTicketHandService swStTicketHandService;
    @Resource
    private final SwStTicketHandDetailService swStTicketHandDetailService;
    @Resource
    private SwStConductorSettleMapper swStConductorSettleMapper;

    /**
     * 分页查询
     *
     * @param page                         分页对象
     * @param swStInputPassengerWorkTicket 乘客事务退换票
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page")
    public R getSwStInputPassengerWorkTicketPage(Page page, SwStInputPassengerWorkTicket swStInputPassengerWorkTicket) {
        String dateCondition = swStInputPassengerWorkTicket.getHandleTimeDTO();
        //LambdaQueryWrapper<SwStInputPassengerWorkTicket> queryWrappers = Wrappers.query(swStInputPassengerWorkTicket).lambda();
		String conductorJobNo = swStInputPassengerWorkTicket.getHandlePersonCode();
		swStInputPassengerWorkTicket.setHandlePersonCode(null);
		swStInputPassengerWorkTicket.setHandlePersonName(null);
        QueryWrapper<SwStInputPassengerWorkTicket> queryWrapper = Wrappers.query(swStInputPassengerWorkTicket);
        queryWrapper.orderByDesc("HANDLE_TIME");
		
		if (StringUtils.isNotBlank(dateCondition)) {
                queryWrapper.lambda().likeRight(SwStInputPassengerWorkTicket::getHandleTime, dateCondition);
            }
		
		if(StringUtils.isNotEmpty(swStInputPassengerWorkTicket.getSourceQueryFlag()) && StringUtils.isNotEmpty(conductorJobNo)){
				queryWrapper.lambda().eq(SwStInputPassengerWorkTicket::getHandlePersonCode,conductorJobNo);//报表路径跳转
		    }
		if(StringUtils.isEmpty(swStInputPassengerWorkTicket.getSourceQueryFlag()) && StringUtils.isNotEmpty(conductorJobNo)){
				queryWrapper.lambda().like(SwStInputPassengerWorkTicket::getHandlePersonCode,conductorJobNo);//售票员工号模糊匹配
		    }

        if (!SecurityUtils.getUser().getBelongToLine()) {
           
            queryWrapper.lambda().eq(SwStInputPassengerWorkTicket::getLineCode, SecurityUtils.getUser().getLineCode());
            queryWrapper.lambda().eq(SwStInputPassengerWorkTicket::getStationCode, SecurityUtils.getUser().getStationCode());
            return R.ok(swStInputPassengerWorkTicketService.page(page, queryWrapper));
		}


        return R.ok(swStInputPassengerWorkTicketService.page(page,queryWrapper));
    }
	/**
     * 分页查询  纺织城或者线网层级查询非即时退换票分页显示
     *
     * @param page                         分页对象
     * @param swStInputPassengerWorkTicket 乘客事务退换票
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/pageLine")
    public R getSwStInputPassengerWorkTicketPageLine(Page page, SwStInputPassengerWorkTicket swStInputPassengerWorkTicket) {
        List<String> dates1 = swStInputPassengerWorkTicket.getDates1();
        //LambdaQueryWrapper<SwStInputPassengerWorkTicket> queryWrappers = Wrappers.query(swStInputPassengerWorkTicket).lambda();
		String conductorJobNo = swStInputPassengerWorkTicket.getHandlePersonCode();
		swStInputPassengerWorkTicket.setHandlePersonCode(null);
		swStInputPassengerWorkTicket.setHandlePersonName(null);
        swStInputPassengerWorkTicket.setOperationType("1");//只查类型是非即时退换票
        QueryWrapper<SwStInputPassengerWorkTicket> queryWrapper = Wrappers.query(swStInputPassengerWorkTicket);
        queryWrapper.ne("INVALID_TICKET_CONFIRM_STATUS", 0);//无效票确认状态为不等于0
        queryWrapper.orderByDesc("HANDLE_TIME");

        if (CollectionUtils.isNotEmpty(dates1)) {
            if (dates1.get(0).equals(dates1.get(1))) {
                queryWrapper.lambda().apply("DATE_FORMAT(handle_time, '%Y-%m-%d') = {0}", dates1.get(0));
            } else {
                queryWrapper.lambda().between(SwStInputPassengerWorkTicket::getHandleTime, dates1.get(0), dates1.get(1));
            }
        }

        if (StringUtils.isNotBlank(swStInputPassengerWorkTicket.getCardOrderSearch())) {
            queryWrapper.lambda().likeRight(SwStInputPassengerWorkTicket::getCardOrder, swStInputPassengerWorkTicket.getCardOrderSearch());
        }
		
		if(StringUtils.isNotEmpty(swStInputPassengerWorkTicket.getSourceQueryFlag()) && StringUtils.isNotEmpty(conductorJobNo)){
				queryWrapper.lambda().eq(SwStInputPassengerWorkTicket::getHandlePersonCode,conductorJobNo);//报表路径跳转
		    }
		if(StringUtils.isEmpty(swStInputPassengerWorkTicket.getSourceQueryFlag()) && StringUtils.isNotEmpty(conductorJobNo)){
				queryWrapper.lambda().like(SwStInputPassengerWorkTicket::getHandlePersonCode,conductorJobNo);//售票员工号模糊匹配
		    }

        return R.ok(swStInputPassengerWorkTicketService.page(page,queryWrapper));
    }

    /**
     * 无效票审核 接收/通知
     * @return
     */
    @RequestMapping("/updateConfirmStatus")
    public R updateConfirmStatus(@RequestBody SwStInputPassengerWorkTicket swStInputPassengerWorkTicket) {
        Integer[] ids = swStInputPassengerWorkTicket.getIds();
        for (int i = 0; i < ids.length; i++) {
            swStInputPassengerWorkTicket.setId(ids[i]);
            swStInputPassengerWorkTicketMapper.updateById(swStInputPassengerWorkTicket);
        }
        return R.ok();
    }

    @RequestMapping("/getPassengerWorkTicket")
    public R getSwStInputPassengerWork(@RequestParam Map<String,String> param){
        List<Map<String, Object>> swStPassengerWorkTicket = swStInputPassengerWorkTicketMapper.getPassengerWorkTicket(param);
        return R.ok(swStPassengerWorkTicket);
    }

    /**
     * 通过id查询乘客事务退换票
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}")
    public R getById(@PathVariable("id") Integer id) {
        return R.ok(swStInputPassengerWorkTicketService.getById(id));
    }

    /**
     * 新增乘客事务退换票
     *
     * @param swStInputPassengerWorkTicket 乘客事务退换票
     * @return R
     */
    @ApiOperation(value = "新增乘客事务退换票", notes = "新增乘客事务退换票")
    @SysLog("新增乘客事务退换票")
    @PostMapping
    @PreAuthorize("@pms.hasPermission('stm_sw_st_input_passenger_work_ticket_add')")
    public R save(@RequestBody SwStInputPassengerWorkTicket swStInputPassengerWorkTicket) {
        swStInputPassengerWorkTicket.setOperationType(TIMELY);
        return R.ok(swStInputPassengerWorkTicketService.save(swStInputPassengerWorkTicket));
    }

    /**
     * 新增非及时退换票
     *
     * @param swStInputPassengerWorkNonTimelyTicket 新增非及时退换票
     * @return R
     */
    @ApiOperation(value = "新增非及时退换票", notes = "新增非及时退换票")
    @SysLog("新增非及时退换票")
    @PostMapping("/saveNonTimely")
    @PreAuthorize("@pms.hasPermission('stm_sw_st_input_passenger_work_ticket_add')")
    public R saveNonTimelyTicket(@RequestBody SwStInputPassengerWorkNonTimelyTicketDTO swStInputPassengerWorkNonTimelyTicket) {
        //获取旧卡号 去掉所有空格
        swStInputPassengerWorkNonTimelyTicket.setCardOrder(BeanUtilsStm.strRemoveBlank(swStInputPassengerWorkNonTimelyTicket.getCardOrder()));
        String cardOrder = swStInputPassengerWorkNonTimelyTicket.getCardOrder();
        SwStInputPassengerWorkTicket serviceOne =
                swStInputPassengerWorkTicketService.getOne(Wrappers.<SwStInputPassengerWorkTicket>lambdaQuery()
                .eq(SwStInputPassengerWorkTicket::getOperationType, "1")
                .eq(SwStInputPassengerWorkTicket::getCardOrder, cardOrder)
                .eq(SwStInputPassengerWorkTicket::getDelFlag, "0"));
        if(ObjectUtil.isNotEmpty(serviceOne)){
            return R.failed("非即时退换票已存在"+serviceOne.getCardOrder()+"的数据，请检查后重新录入！");
        }
        SwStInputPassengerWorkTicket defaultObj = ObjectUtils.getDefaultObj(SwStInputPassengerWorkTicket.class);
        swStInputPassengerWorkNonTimelyTicket.setConductorCode(swStInputPassengerWorkNonTimelyTicket.getHandlePersonCode());
        swStInputPassengerWorkNonTimelyTicket.setConductorName(swStInputPassengerWorkNonTimelyTicket.getHandlePersonName());
        BeanUtils.copyProperties(swStInputPassengerWorkNonTimelyTicket, defaultObj);
        defaultObj.setOperationType(NON_TIMELY);
        defaultObj.setInvalidTicketStatus(CommonConstants.UN_SUBMIT);
        //defaultObj.setInvalidTicketConfirmStatus(CommonConstants.UN_SUBMIT);//无效票确认状态
        return R.ok(swStInputPassengerWorkTicketService.save(defaultObj));
    }

    /**
     * 新增即时退换票
     *
     * @param swStInputPassengerWorkTimelyTicketInput 新增及时退换票
     * @return R
     */
    @ApiOperation(value = "新增及时退换票", notes = "新增及时退换票")
    @SysLog("新增即时退换票")
    @PostMapping("/saveTimely")
    @PreAuthorize("@pms.hasPermission('stm_sw_st_input_passenger_work_ticket_add')")
    public R saveTimelyTicket(@RequestBody SwStInputPassengerWorkTimelyTicketInputDTO swStInputPassengerWorkTimelyTicketInput) {
        List<SwStInputPassengerWorkTicket> swStInputPassengerWorkTicketList = new ArrayList<>();
        swStInputPassengerWorkTimelyTicketInput.setConductorCode(swStInputPassengerWorkTimelyTicketInput.getHandlePersonCode());
        swStInputPassengerWorkTimelyTicketInput.setConductorName(swStInputPassengerWorkTimelyTicketInput.getHandlePersonName());
        swStInputPassengerWorkTimelyTicketInput.setDeviceOperateNum(BeanUtilsStm.strRemoveBlank(swStInputPassengerWorkTimelyTicketInput.getDeviceOperateNum()));
        swStInputPassengerWorkTimelyTicketInput.getSwStInputPassengerWorkTimelyTicketList().forEach(item -> {
            item.setCardOrder(BeanUtilsStm.strRemoveBlank(item.getCardOrder()));
            SwStInputPassengerWorkTicket defaultObj = ObjectUtils.getDefaultObj(SwStInputPassengerWorkTicket.class);
            defaultObj.setOperationType(TIMELY);
            BeanUtils.copyProperties(item, defaultObj);
            BeanUtils.copyProperties(swStInputPassengerWorkTimelyTicketInput, defaultObj);
            swStInputPassengerWorkTicketList.add(defaultObj);
        });
        return R.ok(swStInputPassengerWorkTicketService.saveBatch(swStInputPassengerWorkTicketList));
    }

    /**
     * 修改乘客事务退换票
     *
     * @param swStInputPassengerWorkTicket 乘客事务退换票
     * @return R
     */
    @ApiOperation(value = "修改乘客事务退换票", notes = "修改乘客事务退换票")
    @SysLog("修改乘客事务退换票")
    @PutMapping
    @PreAuthorize("@pms.hasPermission('stm_sw_st_input_passenger_work_ticket_edit')")
    @Transactional(rollbackFor = Exception.class)
    public R updateById(@RequestBody SwStInputPassengerWorkTicket swStInputPassengerWorkTicket) {
        //获取旧卡号 去掉所有空格
        swStInputPassengerWorkTicket.setCardOrder(BeanUtilsStm.strRemoveBlank(swStInputPassengerWorkTicket.getCardOrder()));
        //反查车票金额
        String replaceTicketType = swStInputPassengerWorkTicket.getReplaceTicketType();
        if(StringUtils.isNotEmpty(replaceTicketType)){
            String replaceTicketName = swStInputPassengerWorkTicket.getReplaceTicketName();
            SwPmTicketCardTypeParam paramServiceOne =
                    swPmTicketCardTypeParamService.getOne(Wrappers.<SwPmTicketCardTypeParam>lambdaQuery()
                            .eq(SwPmTicketCardTypeParam::getMainEnName, replaceTicketType)
                            .eq(SwPmTicketCardTypeParam::getSubEnName, replaceTicketName)
                            .eq(SwPmTicketCardTypeParam::getDelFlag, "0"));
            BigDecimal ticketAmount = Optional.ofNullable(paramServiceOne.getTicketAmount()).orElse(new BigDecimal("0"));
            swStInputPassengerWorkTicket.setTicketPrice(ticketAmount);
        }

        SwStInputPassengerWorkTicket workTicket = swStInputPassengerWorkTicketService.getById(swStInputPassengerWorkTicket.getId());
        if(ObjectUtil.isNotEmpty(workTicket)){
            String submitStatus = workTicket.getSubmitStatus();
            if("1".equals(submitStatus)){
                return R.failed(StmConstans.failedEdit);
            }
        }
        PigxUser user = SecurityUtils.getUser();
        if("1".equals(workTicket.getReportModifyStatus())){
            swStInputPassengerWorkTicket.setEntryUpdateJobNo(user.getUserCode());
            swStInputPassengerWorkTicket.setEntryUpdateJobName(user.getNikeName());
            swStInputPassengerWorkTicket.setEntryUpdateTime(new Date());

            SwStmStationDataEntryLog swStmStationDataEntryLog = new SwStmStationDataEntryLog();
            swStmStationDataEntryLog.setRelationId(workTicket.getId());
            swStmStationDataEntryLog.setLogTableName(StmTableCommon.SW_ST_INPUT_PASSENGER_WORK_TICKET);
            swStmStationDataEntryLog.setLogInfo(JSONObject.toJSONString(workTicket));
            swStmStationDataEntryLog.setUpdateJobNo(user.getUserCode());
            swStmStationDataEntryLog.setUpdateJobName(user.getNikeName());
            swStmStationDataEntryLog.setUpdateTime(new Date());
            swStmStationDataEntryLogService.save(swStmStationDataEntryLog);
            if("1".equals(workTicket.getIsMerge())){
                swStInputPassengerWorkTicket.setConfirmStatus("1");
            }else{
			    swStInputPassengerWorkTicket.setConfirmStatus("0");
			}

			/*//报表修改状态，非即时退换票才会有评估次数。  20240226   "操作类型 0:及时退换票;1:非及时退换票"    private String operationType;
			if("0".equals(workTicket.getOperationType())){//即时时把预估次数设置为null
			    swStInputPassengerWorkTicket.setEstimatedNumber(null);
			}*/

        }else{
		     swStInputPassengerWorkTicket.setConfirmStatus("0");
		}

        QueryWrapper<SwStConductorSettle> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("LINE_CODE", workTicket.getLineCode());
        queryWrapper.eq("STATION_CODE", workTicket.getStationCode());
        queryWrapper.eq("CONDUCTOR_JOB_NO", workTicket.getConductorCode());
        queryWrapper.eq("DEVICE_OPERATE_NUM", workTicket.getDeviceOperateNum());
        queryWrapper.eq("CONDUCTOR_SHIFTS", workTicket.getClassNumber());
		queryWrapper.eq("DEL_FLAG", "0"); //未删除状态
		queryWrapper.eq("APPROVAL_STATUS", "0"); //未提交状态才修改，否则不要动
		queryWrapper.eq("CONFIRM_STATUS", "1"); //已确认状态才修改，否则不要动
        queryWrapper.apply("DATE_FORMAT(WORKING_START_TIME, '%Y-%m-%d') = DATE_FORMAT('"+workTicket.getHandleTime()+"', '%Y-%m-%d')");
        List<SwStConductorSettle> swStConductorSettles = swStConductorSettleMapper.selectList(queryWrapper);
        if (CollectionUtil.isNotEmpty(swStConductorSettles)) {
            SwStConductorSettle swStConductorSettle = swStConductorSettles.get(0);
            swStConductorSettle.setConfirmStatus("0");
            swStConductorSettleMapper.updateById(swStConductorSettle);
        }

        //非即时退换票才会有评估次数。  20240226   "操作类型 0:及时退换票;1:非及时退换票"    private String operationType;
        if("0".equals(workTicket.getOperationType())){//即时时把预估次数设置为null
            swStInputPassengerWorkTicket.setEstimatedNumber(null);
        }
        return R.ok(swStInputPassengerWorkTicketService.updateById(swStInputPassengerWorkTicket));
    }

    /**
     * 通过id查询乘客事务退换票历史记录
     *
     * @param  id
     * @return R
     */
    @ApiOperation(value = "通过id查询乘客事务退换票历史记录", notes = "通过id查询乘客事务退换票历史记录")
    @GetMapping("getLogById/{id}")
    public R getLogById(@PathVariable("id") Integer id) {
        List<Object> LogInfoList = new ArrayList<>();
        List<SwStmStationDataEntryLog> swStmStationDataEntryLogs = swStmStationDataEntryLogService.getBaseMapper()
                .selectList(Wrappers.<SwStmStationDataEntryLog>lambdaQuery()
                .eq(SwStmStationDataEntryLog::getRelationId, id)
                .eq(SwStmStationDataEntryLog::getLogTableName, StmTableCommon.SW_ST_INPUT_PASSENGER_WORK_TICKET));
        //返回json串
        if(CollectionUtil.isNotEmpty(swStmStationDataEntryLogs)){
            swStmStationDataEntryLogs.stream().forEach(x -> {
                JSONObject jsonObject = JSONObject.parseObject(x.getLogInfo());
                LogInfoList.add(jsonObject);
            });
        }
        //List<String> LogInfoList = swStmStationDataEntryLogs.stream().map(SwStmStationDataEntryLog::getLogInfo).collect(Collectors.toList());
        return R.ok(LogInfoList);
    }

    /**
     * 通过id删除乘客事务退换票
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除乘客事务退换票", notes = "通过id删除乘客事务退换票")
    @SysLog("通过id删除乘客事务退换票")
    @DeleteMapping("/{id}")
    @PreAuthorize("@pms.hasPermission('stm_sw_st_input_passenger_work_ticket_del')")
    public R removeById(@PathVariable Integer id) {
        return R.ok(swStInputPassengerWorkTicketService.removeById(id));
    }

    /**
     * 通过id批量删除乘客事务退换票
     *
     * @param idList id
     * @return R
     */
    @ApiOperation(value = "通过id批量删除乘客事务退换票", notes = "通过id批量删除乘客事务退换票")
    @SysLog("通过id批量删除乘客事务退换票")
    @PostMapping("/batchDelete")
    @PreAuthorize("@pms.hasPermission('stm_sw_st_input_passenger_work_ticket_del')")
    public R batchDeleteById(@RequestBody List<Integer> idList) {
        List<Integer> deleteList = new ArrayList<>();
        List<SwStInputPassengerWorkTicket> arrayList = new ArrayList<>();
        idList.forEach(id -> {
            SwStInputPassengerWorkTicket swStInputPassengerWorkTicket = swStInputPassengerWorkTicketService.getById(id);
            if (CommonConstants.SUBMIT.equals(swStInputPassengerWorkTicket.getSubmitStatus())) {
                log.info("已提交数据不能删除！");
            } else {
                deleteList.add(id);
                arrayList.add(swStInputPassengerWorkTicket);
            }
        });
        if(CollectionUtil.isEmpty(deleteList)){
            return R.failed(StmConstans.failedDelete);
        }
        for (SwStInputPassengerWorkTicket swStInputPassengerWorkTicket : arrayList) {
            //如果是即时退换票的去删除
            /* 20241112 去掉票卡信息关联
			if("0".equals(swStInputPassengerWorkTicket.getOperationType())){
                //根据原卡号查询删除收入审核票卡信息查询
                swStTicketInformationCheckService.remove(Wrappers.<SwStTicketInformationCheck>lambdaQuery()
                        .eq(SwStTicketInformationCheck::getCardOrder,swStInputPassengerWorkTicket.getCardOrder())
                        .eq(SwStTicketInformationCheck::getDelFlag,"0"));
            }*/
            //如果是非即时退换票的去关联删除
            if("1".equals(swStInputPassengerWorkTicket.getOperationType())){
                swStInvalidTicketMapper.delete(Wrappers.<SwStInvalidTicket>lambdaQuery()
                        .eq(SwStInvalidTicket::getStationLine, swStInputPassengerWorkTicket.getLineCode())
                        .eq(SwStInvalidTicket::getStationCode, swStInputPassengerWorkTicket.getStationCode())
                        .eq(SwStInvalidTicket::getOldCardOrder, swStInputPassengerWorkTicket.getCardOrder())
                        .eq(SwStInvalidTicket::getDelFlag, "0"));
                //改变报表差错修改状态
                if("1".equals(swStInputPassengerWorkTicket.getIsAddReprotError())){
                    QueryWrapper<SwStReportErrorAlterApply> wrappers = new QueryWrapper<>();
                    wrappers.lambda().eq(SwStReportErrorAlterApply::getLineCode,swStInputPassengerWorkTicket.getLineCode())
                            .eq(SwStReportErrorAlterApply::getStationCode,swStInputPassengerWorkTicket.getStationCode())
                            .eq(SwStReportErrorAlterApply::getReprotTime,swStInputPassengerWorkTicket.getHandleTime().toLocalDate())
                            .eq(SwStReportErrorAlterApply::getDeviceNo,swStInputPassengerWorkTicket.getDeviceOperateNum())
                            .eq(SwStReportErrorAlterApply::getDelFlag,"0")
                            .ne(SwStReportErrorAlterApply::getIsModify,"1")//不等于1
                            .ne(SwStReportErrorAlterApply::getCheckStatus,"4")
                            .eq(SwStReportErrorAlterApply::getReportNameId,"9");//非即时退换票
                    SwStReportErrorAlterApply swStReportErrorAlterApply = new SwStReportErrorAlterApply();
                    swStReportErrorAlterApply.setIsModify("1");
                    swStReportErrorAlterApply.setModifyTime(new Date());
                    swStReportErrorAlterAppayMapper.update(swStReportErrorAlterApply,wrappers);
                }
            }
        }
        return R.ok(swStInputPassengerWorkTicketService.removeByIds(deleteList));
    }

    /**
     * 批量提交乘客事务退换票录入数据
     *
     * @param idList
     * @return
     */
    @ApiOperation(value = "批量提交乘客事务退换票录入数据", notes = "批量提交乘客事务退换票录入数据")
    @SysLog("批量提交乘客事务退换票录入数据")
    @PostMapping("/submit")
    @PreAuthorize("@pms.hasPermission('stm_sw_st_input_passenger_work_ticket_submit')")
    public R submit(@RequestBody List<Integer> idList) {
        //TODO 此处提交，要发送到 收入审核-票卡信息查询 模块中 ，票卡信息查询，加入ACC协查后，到达清分应用回馈车站提交票卡信息
        List<SwStInputPassengerWorkTicket> submitList = new ArrayList<>();
        idList.forEach(id -> {
            SwStInputPassengerWorkTicket submitItem = new SwStInputPassengerWorkTicket();
            submitItem.setId(id);
            submitItem.setSubmitStatus(CommonConstants.SUBMIT);
            submitList.add(submitItem);
        });
        return R.ok(swStInputPassengerWorkTicketService.updateBatchById(submitList));
    }


    /**
     * 发送非及时退换票到无效票
     *
     * @param ids
     * @return
     */
    @ApiOperation(value = "发送非及时退换票到无效票", notes = "发送非及时退换票到无效票")
    @SysLog("发送非及时退换票到无效票")
    @GetMapping("/send/{ids}")
    @PreAuthorize("@pms.hasPermission('stm_sw_st_input_passenger_work_ticket_send_invalid')")
    public R sendInvalid(@PathVariable String[] ids) {
        PigxUser user = SecurityUtils.getUser();
        /* 20241112 无效票发送不插入新的业务表
		List<SwStInputPassengerWorkTicket> workTicketArrayList = new ArrayList<>();
        List<SwStInvalidTicketDTO> dtoArrayList = new ArrayList<>();
        for (String id : ids) {
            SwStInputPassengerWorkTicket sendItem  = swStInputPassengerWorkTicketService.getById(id);
            //QueryWrapper<SwStInvalidTicket> wrapper = new QueryWrapper<>();
            //wrapper.lambda().eq(SwStInvalidTicket::getStationLine,sendItem.getLineCode())
            //        .eq(SwStInvalidTicket::getStationCode,sendItem.getStationCode())
            //        .eq(SwStInvalidTicket::getOldCardOrder,sendItem.getCardOrder());
            //List<SwStInvalidTicket> invalidTicket =  swStInvalidTicketMapper.selectList(wrapper);
            //if(invalidTicket.size()>0){
            //    return R.failed("卡号为'"+sendItem.getCardOrder()+"'的数据已存在并已发送无效票，不允许重复发送此卡号的无效票");
            //}
            if (TIMELY.equals(sendItem.getOperationType()) || SEND.equals(sendItem.getInvalidTicketStatus())) {
                return R.failed("只能发送非即时退换票,且未发送到无效票");
            }
            SwStInvalidTicketDTO dto = new SwStInvalidTicketDTO();
            dto.setStationLine(sendItem.getLineCode());
            dto.setStationCode(sendItem.getStationCode());
            dto.setTicketType(sendItem.getTicketType());
            dto.setTicketName(sendItem.getTicketName());
            dto.setOldCardOrder(sendItem.getCardOrder());
            dto.setClassNumber(sendItem.getClassNumber());//班次
            //dto.setCardIssuerId(Integer.valueOf(sendItem.getHandlePersonCode()));//办理人工号
            //dto.setCardIssuer(sendItem.getHandlePersonName());//办理人
            dto.setCreatorName(user.getNikeName());
            dto.setDataSource(STATION);
            dto.setCreatorId(user.getId());
            dto.setEstimatedNumber(sendItem.getEstimatedNumber());//预估次数
            dto.setInputStatus("0");//入库状态
            dto.setOutputStatus("0");//出库状态
            dtoArrayList.add(dto);
            workTicketArrayList.add(sendItem);
        }

        //无效票批量发送
        if(CollectionUtil.isNotEmpty(dtoArrayList)){
            R r = subwayStService.invalidTicketSave(SecurityConstants.FROM_IN, dtoArrayList);
            if (CommonConstants.SUCCESS == r.getCode()) {
                for (SwStInputPassengerWorkTicket ticket : workTicketArrayList) {
                    ticket.setInvalidTicketStatus(SEND);//无效票已发送
                    ticket.setInvalidTicketConfirmStatus(CommonConstants.INSEND);//无效票已发送
                    ticket.setSubmitStatus(CommonConstants.SUBMIT);//提交状态已提交
                    ticket.setConfirmStatus(CommonConstants.CONFIRM);//确认状态已确认
                    ticket.setReportModifyStatus("0");//报表差错修改状态已完成

                    //改变报表差错修改状态
                    if("1".equals(ticket.getIsAddReprotError())){
                        QueryWrapper<SwStReportErrorAlterApply> wrappers = new QueryWrapper<>();
                        wrappers.lambda().eq(SwStReportErrorAlterApply::getLineCode,ticket.getLineCode())
                                .eq(SwStReportErrorAlterApply::getStationCode,ticket.getStationCode())
                                .eq(SwStReportErrorAlterApply::getReprotTime, ticket.getHandleTime().toLocalDate())
                                .eq(SwStReportErrorAlterApply::getDeviceNo,ticket.getDeviceOperateNum())
                                .eq(SwStReportErrorAlterApply::getDelFlag,"0")
                                .ne(SwStReportErrorAlterApply::getIsModify,"1")//不等于1
                                .ne(SwStReportErrorAlterApply::getCheckStatus,"4")
                                .eq(SwStReportErrorAlterApply::getReportNameId,"9");//非即时退换票
                        SwStReportErrorAlterApply swStReportErrorAlterApply = new SwStReportErrorAlterApply();
                        swStReportErrorAlterApply.setIsModify("1");
                        swStReportErrorAlterApply.setModifyTime(new Date());
                        swStReportErrorAlterAppayMapper.update(swStReportErrorAlterApply,wrappers);
                    }
                }
                swStInputPassengerWorkTicketService.updateBatchById(workTicketArrayList);
            }
        }*/

		List<SwStInputPassengerWorkTicket> workTicketArrayList = new ArrayList<>();
		for (String id : ids) {
            SwStInputPassengerWorkTicket ticket  = swStInputPassengerWorkTicketService.getById(id);
            if (TIMELY.equals(ticket.getOperationType()) || SEND.equals(ticket.getInvalidTicketStatus())) {
                return R.failed("只能发送非即时退换票,且未发送到无效票");
            }
			ticket.setInvalidTicketStatus(SEND);//无效票已发送
            ticket.setInvalidTicketConfirmStatus(CommonConstants.INSEND);//无效票已发送
            ticket.setSubmitStatus(CommonConstants.SUBMIT);//提交状态已提交
            ticket.setConfirmStatus(CommonConstants.CONFIRM);//确认状态已确认
            ticket.setReportModifyStatus("0");//报表差错修改状态已完成
			workTicketArrayList.add(ticket);
			 //改变报表差错修改状态
              if("1".equals(ticket.getIsAddReprotError())){
                        QueryWrapper<SwStReportErrorAlterApply> wrappers = new QueryWrapper<>();
                        wrappers.lambda().eq(SwStReportErrorAlterApply::getLineCode,ticket.getLineCode())
                                .eq(SwStReportErrorAlterApply::getStationCode,ticket.getStationCode())
                                .eq(SwStReportErrorAlterApply::getReprotTime, ticket.getHandleTime().toLocalDate())
                                .eq(SwStReportErrorAlterApply::getDeviceNo,ticket.getDeviceOperateNum())
                                .eq(SwStReportErrorAlterApply::getDelFlag,"0")
                                .ne(SwStReportErrorAlterApply::getIsModify,"1")//不等于1
                                .ne(SwStReportErrorAlterApply::getCheckStatus,"4")
                                .eq(SwStReportErrorAlterApply::getReportNameId,"9");//非即时退换票
                        SwStReportErrorAlterApply swStReportErrorAlterApply = new SwStReportErrorAlterApply();
                        swStReportErrorAlterApply.setIsModify("1");
                        swStReportErrorAlterApply.setModifyTime(new Date());
                        swStReportErrorAlterAppayMapper.update(swStReportErrorAlterApply,wrappers);
               }
        
        }
		if(CollectionUtil.isNotEmpty(workTicketArrayList)){
			 swStInputPassengerWorkTicketService.updateBatchById(workTicketArrayList);
		}  
		//20241112修改完成
        return R.ok();

    }

    /**
     * 车站确认线网无效票完善通知，仅供线网临时无效票完善模块内部调用
     *
     * @param list
     * @return
     */
    @Inner
    @ApiOperation(value = "车站确认线网无效票完善通知", notes = "车站确认线网无效票完善通知")
    @PostMapping("/completeConfirm")
    public R testConfirm(@Valid @RequestBody List<SwStInputPassengerWorkTicket> list) {
        List<SwStInputPassengerWorkTicket> testConfirmList = new ArrayList<>();
        list.forEach(item -> {
            LambdaQueryWrapper<SwStInputPassengerWorkTicket> queryWrapper = new LambdaQueryWrapper<>();
            queryWrapper.eq(SwStInputPassengerWorkTicket::getReplaceCardOrder, item.getReplaceCardOrder());//新卡号
            queryWrapper.eq(SwStInputPassengerWorkTicket::getDelFlag,"0");
            SwStInputPassengerWorkTicket workTicketServiceOne = swStInputPassengerWorkTicketService.getOne(queryWrapper);
            if(workTicketServiceOne!=null){
                workTicketServiceOne.setInvalidTicketConfirmStatus(item.getInvalidTicketConfirmStatus());//已完善
                testConfirmList.add(workTicketServiceOne);
            }
        });
        if(testConfirmList.size()>0){
            return R.ok(swStInputPassengerWorkTicketService.updateBatchById(testConfirmList));
        }
        return R.ok();
    }

    /**
     * 线网添加的无效票生产审批通过后到非及时退换票
     *
     * @param swStInputPassengerWorkTicketList
     * @return R
     */
    @ApiOperation(value = "线网添加的无效票生产审批通过后到非及时退换票", notes = "线网添加的无效票生产审批通过后到非及时退换票")
    @PostMapping("/innerTickerSave")
    @Inner
    public R feignTicket(@Valid @RequestBody List<SwStInputPassengerWorkTicket> swStInputPassengerWorkTicketList) {
        return R.ok(swStInputPassengerWorkTicketService.saveBatch(swStInputPassengerWorkTicketList));
    }

    /**
     * 线网审批通过后修改车站状态
     *
     * @param
     * @return R
     */
    @ApiOperation(value = "线网审批通过后修改车站状态", notes = "线网审批通过后修改车站状态")
    @PostMapping("/innerTickerUpdateBach")
    @Inner
    public R feignTicketUpdateBach(@Valid @RequestBody List<SwStInputPassengerWorkTicket> list) {
        ArrayList<SwStInputPassengerWorkTicket> arrayList = new ArrayList<>();
        list.forEach(item ->{
            QueryWrapper<SwStInputPassengerWorkTicket> wrapper = new QueryWrapper<>();
            wrapper.lambda().eq(SwStInputPassengerWorkTicket::getCardOrder,item.getCardOrder());
            wrapper.lambda().eq(SwStInputPassengerWorkTicket::getDelFlag,"0");
            SwStInputPassengerWorkTicket swStInputPassengerWorkTicket = swStInputPassengerWorkTicketService.getOne(wrapper);
            swStInputPassengerWorkTicket.setInvalidTicketConfirmStatus(item.getInvalidTicketConfirmStatus());//车站无效票审批通过
            arrayList.add(swStInputPassengerWorkTicket);
        });
        if(arrayList.size()>0){

            return R.ok(swStInputPassengerWorkTicketService.updateBatchById(arrayList));
        }
        return R.ok();
    }

    /**
     * 线网完善信息后车站添加新卡号
     *
     * @param
     * @return R
     */
    @ApiOperation(value = "线网完善信息后车站添加新卡号", notes = "线网完善信息后车站添加新卡号")
    @PostMapping("/innerTicketUpdate")
    @Inner
    public R feignTicketUpdate(@Valid @RequestBody SwStInputPassengerWorkTicket InputPassengerWorkTicket) {
        QueryWrapper<SwStInputPassengerWorkTicket> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(SwStInputPassengerWorkTicket::getCardOrder,InputPassengerWorkTicket.getCardOrder());
        wrapper.lambda().eq(SwStInputPassengerWorkTicket::getDelFlag,"0");
        wrapper.lambda().eq(SwStInputPassengerWorkTicket::getInvalidTicketStatus,"1");
        List<SwStInputPassengerWorkTicket> swStInputPassengerWorkTicket = swStInputPassengerWorkTicketService.list(wrapper);
        List<SwStInputPassengerWorkTicket> passengerWorkTicket = new ArrayList<>();
        if(CollectionUtil.isNotEmpty(swStInputPassengerWorkTicket)){
            for(SwStInputPassengerWorkTicket item : swStInputPassengerWorkTicket){
                item.setReplaceCardOrder(InputPassengerWorkTicket.getReplaceCardOrder());
                item.setActiveTime(InputPassengerWorkTicket.getActiveTime());
                item.setTicketTimes(InputPassengerWorkTicket.getTicketTimes());
                passengerWorkTicket.add(item);
            }
            return R.ok(swStInputPassengerWorkTicketService.updateBatchById(passengerWorkTicket));
        }
        return R.failed();
    }

    /**
     * 批量确认领取乘客事务非即时退换票
     *
     * @param idList
     * @return
     */
    @ApiOperation(value = "批量确认领取乘客事务非即时退换票", notes = "批量确认领取乘客事务非即时退换票")
    @SysLog("批量确认领取乘客事务非即时退换票")
    @PutMapping("/confirm")
    @PreAuthorize("@pms.hasPermission('stm_sw_st_input_passenger_work_ticket_confirm')")
    public R confirm(@RequestBody List<Integer> idList) {
        List<SwStInputPassengerWorkTicket> confirmList = new ArrayList<>();
        List<SwStInvalidTicketDTO> InvalidTicketList = new ArrayList<>();
        idList.forEach(id -> {
            SwStInputPassengerWorkTicket confirmItem = new SwStInputPassengerWorkTicket();
            SwStInvalidTicketDTO swStInvalidTicketDTO = new SwStInvalidTicketDTO();
            confirmItem.setId(id);
            confirmItem.setInvalidTicketConfirmStatus(CommonConstants.INCONFIRM);

            //标记无效票管理为已确认
            SwStInputPassengerWorkTicket byId = swStInputPassengerWorkTicketService.getById(id);
            swStInvalidTicketDTO.setOldCardOrder(byId.getCardOrder());
            confirmList.add(confirmItem);
            InvalidTicketList.add(swStInvalidTicketDTO);
        });
        if(confirmList.size()>0){
           swStInputPassengerWorkTicketService.updateBatchById(confirmList);
           //subwayStService.invalidTicketUpdateBatch(SecurityConstants.FROM_IN,InvalidTicketList);  20241112确认后不再关联相关另一个表
        }
        return R.ok();
    }


    /**
     * 根据id去无效票查询对应的数据，已发送的数据或已入库的数据车站不能申请报表差错
     * @param id
     * @return R
     */
    @ApiOperation(value = "根根据id去无效票查询对应的数据，已发送的数据或已入库的数据车站不能申请报表差错", notes = "根据id去无效票查询对应的数据，已发送的数据或已入库的数据车站不能申请报表差错")
    @SysLog("根据id去无效票查询对应的数据，已发送的数据或已入库的数据车站不能申请报表差错")
    @GetMapping("/queryIds")
    public R queryIds(@RequestParam("id") String id) {
        SwStInputPassengerWorkTicket serviceById = swStInputPassengerWorkTicketService.getById(id);
        if(ObjectUtil.isNotEmpty(serviceById)){
            LambdaQueryWrapper<SwStInvalidTicket> queryWrapper =
                    Wrappers.<SwStInvalidTicket>lambdaQuery()
                            .eq(SwStInvalidTicket::getOldCardOrder, serviceById.getCardOrder())
                            .eq(SwStInvalidTicket::getStationLine, serviceById.getLineCode())
                            .eq(SwStInvalidTicket::getStationCode, serviceById.getStationCode())
                            .eq(SwStInvalidTicket::getDataSource, "0")//数据来源是车站的
                            .eq(SwStInvalidTicket::getDelFlag, "0");
            SwStInvalidTicket selectOne = swStInvalidTicketMapper.selectOne(queryWrapper);
            if(ObjectUtil.isNotEmpty(selectOne)){
                boolean b =
                        "1".equals(selectOne.getOutputStatus()) || "1".equals(selectOne.getInputStatus()) || !"0".equals(selectOne.getCheckStatus());
                if(b){
                    return R.failed("该数据在无效票管理中已发送到无效票生产申请或已出入库，不允许加入报表差错！");
                }
            }
        }
        return R.ok();
    }

    @ApiOperation(value = "加入车票上交", notes = "加入车票上交")
    @SysLog("加入车票上交")
    @GetMapping("/addTicketHand/{ids}")
    public R addTicketHand(@PathVariable String[] ids) {
        PigxUser user = SecurityUtils.getUser();
        List<SwStTicketHandDetail> handDetailList = new ArrayList<>();
        Collection<SwStInputPassengerWorkTicket> swStInputPassengerWorkTickets =
                swStInputPassengerWorkTicketService.listByIds(Arrays.asList(ids));
        if(CollectionUtil.isNotEmpty(swStInputPassengerWorkTickets)){
            SwStTicketHand defaultObj = ObjectUtils.getDefaultObj(SwStTicketHand.class);
            //车站自己添加的数据，默认通知状态置成已通知且已确认
            defaultObj.setDataSource(StmConstans.TICKET_HAND_DATASOURCE_STATION);//数据来源车站
            defaultObj.setNoticeStatus(CommonConstants.INFORMED);
            defaultObj.setNoticeConfirm(CommonConstants.CONFIRM);
            defaultObj.setHandStatus(CommonConstants.UN_CONFIRM);//回收状态 0:待确认
            defaultObj.setHandPersonName(user.getNikeName());//上交人默认当前登录人
            defaultObj.setHandPersonCode(user.getUserCode());
            defaultObj.setHandTime(LocalDateTime.now());//上交时间默认当前时间
            int count = (int) swStInputPassengerWorkTickets.stream().count();
            defaultObj.setHandCount(count);
            swStTicketHandService.save(defaultObj);
            for (SwStInputPassengerWorkTicket swStInputPassengerWorkTicket : swStInputPassengerWorkTickets) {
                SwStTicketHandDetail swStTicketHandDetail = new SwStTicketHandDetail();
                swStTicketHandDetail.setTicketType(swStInputPassengerWorkTicket.getTicketType());//票种
                swStTicketHandDetail.setTicketName(swStInputPassengerWorkTicket.getTicketName());//车票名称
                swStTicketHandDetail.setTicketCount("0");//次数金额默认为0
                swStTicketHandDetail.setTicketAmount(new BigDecimal("0"));
                swStTicketHandDetail.setHandCount(1);//上交数量默认1
                swStTicketHandDetail.setCardNumber(swStInputPassengerWorkTicket.getCardOrder());//卡号
                //关联主表id
                swStTicketHandDetail.setRefId(defaultObj.getId());
                handDetailList.add(swStTicketHandDetail);

                //修改车票上交状态
                swStInputPassengerWorkTicket.setHandStatus("1");//加入车票上交状态为已加入
            }
            swStInputPassengerWorkTicketService.updateBatchById(swStInputPassengerWorkTickets);
            return R.ok(swStTicketHandDetailService.saveBatch(handDetailList));
        }
        return R.failed("没有可加入的数据！");

    }

    @ApiOperation(value = "加入人工回收", notes = "加入人工回收")
    @SysLog("加入人工回收")
    @GetMapping("/addRecovery/{ids}")
    public R addRecovery(@PathVariable String[] ids) {
        PigxUser user = SecurityUtils.getUser();
        List<SwStRecovery> objects = new ArrayList<>();
        Collection<SwStInputPassengerWorkTicket> swStInputPassengerWorkTickets =
                swStInputPassengerWorkTicketService.listByIds(Arrays.asList(ids));
        if(CollectionUtil.isNotEmpty(swStInputPassengerWorkTickets)){
            for (SwStInputPassengerWorkTicket swStInputPassengerWorkTicket : swStInputPassengerWorkTickets) {
                SwStRecovery defaultObj = ObjectUtils.getDefaultObj(SwStRecovery.class);
                defaultObj.setTicketType(swStInputPassengerWorkTicket.getTicketType());//票种
                defaultObj.setTicketName(swStInputPassengerWorkTicket.getTicketName());//车票名称
                defaultObj.setTicketCount("0");//次数金额默认为0
                defaultObj.setTicketAmount(new BigDecimal("0"));
                defaultObj.setRecoverNumber("1");//回收数量默认1
                defaultObj.setRecoverPersonName(user.getNikeName());//回收人默认当前登录人
                defaultObj.setRecoverPersonCode(user.getUserCode());
                defaultObj.setRecoverTime(LocalDateTime.now());//回收时间默认当前时间
                objects.add(defaultObj);

                //修改人工回收状态
                swStInputPassengerWorkTicket.setRecoveryStatus("1");//加入人工回收状态为已加入
            }
            swStInputPassengerWorkTicketService.updateBatchById(swStInputPassengerWorkTickets);
            return R.ok(swStRecoveryService.saveBatch(objects));
        }
        return R.failed("没有可加入的数据！");
    }
	/**
     * 修改完善无效票信息  20241112增加
     * @param swStInvalidTicket
     * @return
     */
    @PutMapping("/completeInval")
    @ApiOperation(value = "修改完善无效票信息", notes = "修改完善无效票信息")
    @SysLog("修改完善无效票信息")
    //@PreAuthorize("@pms.hasPermission('st_invalid_ticket_completeInval')")
    public R updateInvalidById(@Valid @RequestBody SwStInputPassengerWorkTicket swStInputPassengerWorkTicket) {
       PigxUser user = SecurityUtils.getUser();
       swStInputPassengerWorkTicket.setInvalidTicketConfirmStatus("4");
        boolean b = swStInputPassengerWorkTicketService.updateById(swStInputPassengerWorkTicket);
        if(b){
           return R.ok();
        }
       return R.failed("完善信息失败！");
    }
	/**
     * 纺织城站修改无效票状态  20241112增加
     * @param swStInvalidTicket
     * @return
     */
    @PutMapping("/fangzhichengStatus")
    @ApiOperation(value = "纺织城站修改无效票状态", notes = "纺织城站修改无效票状态")
    @SysLog("纺织城站修改无效票状态")
    public R updateFangzhichengInvalidById(@Valid @RequestBody SwStInputPassengerWorkTicket swStInputPassengerWorkTicket) {
       PigxUser user = SecurityUtils.getUser();
        //swStInputPassengerWorkTicket.setInvalidTicketConfirmStatus("4");
        boolean b = swStInputPassengerWorkTicketService.updateById(swStInputPassengerWorkTicket);
        if(b){
           return R.ok();
        }
       return R.failed("操作状态失败！");
    }
}
